<template>
	<view class="content">
		<view class="status_bar">
			  <!-- 这里是状态栏 --> 
		</view>
			<uni-nav-bar left-icon="back" left-text="返回"  :title="(typeList[a-1]).title" @tap="back"></uni-nav-bar>
			<!-- 内容 -->
				<view class="uni-product-list">
					<view class="uni-product" v-for="(i,index) in listdata" :key=index >
						<navigator :url="'/pages/info?id='+i.wares_id"> 
							<view class="image-view">
								<image class="uni-product-image" :src="JSON.parse(i.wares_masterimg)[0]"></image>
							</view>
							<view class="uni-product-title">{{i.wares_title}}</view>
							<view class="uni-product-price">
								<text class="uni-product-price-favour">￥{{i.wares_nowprice}}</text>
								<text class="uni-product-price-original">￥{{i.wares_oldprice}}</text>
							</view>
						</navigator>	
					</view>
				</view>
			<!-- 内容 -->
		

		
	</view>
</template>

<script>
	import uniNavBar from "@/components/uniapp/uni-nav-bar/uni-nav-bar.vue"
	export default {
		data() {
			return {
				a:null,
				listdata:[],
				 typeList: [
				        { id: 1, title: "限时白嫖" },
				        { id: 2, title: "新品推荐" },
				        { id: 3, title: "低价高配" },
				        { id: 4, title: "超值特卖" }
				      ]
			};
		},
		methods:{
			back(){
				uni.navigateBack();
			},
			async getList() {
				var data = await this.$http.homeService.getListData({
					id: this.a
				});
				
				 this.listdata = data.result
				 console.log(this.listdata)
			},
		},
		components: {uniNavBar},
		onLoad (option) { //option为object类型，会序列化上个页面传递的参数
			console.log("id 为:",option.id); //打印出上个页面传递的参数。
			this.a = option.id
			this.getList();
		 }
	}
</script>

<style lang="stylus" scoped>
	@import "../common/styl/page/list.styl"
	.status_bar
		height: var(--status-bar-height);
		width: 100%;
</style>
